<?php
namespace app\wenchuang\validate;

use think\Validate;

class ArticleWorkValidate extends Validate
{
    // 定义验证规则
    protected $rule = [
        'title' => 'require|max:30',
        'abstract' => 'max:100',
        'author' => 'max:15',
        'id' => 'require'
    ];

    // 定义提示信息
    protected $message = [
        'title.require' => '请填写文章标题',
        'title.max' => '标题最多30个字符',
        'abstract.max' => '摘要最多100个字符',
        'author.max' => '作者最多15个字符',
        'id.require' => '数据错误，缺少 id ！',
    ];

    // 验证场景
    protected $scene = [
        'add' => ['title'],
        'edit' => ['title', 'id']
    ];
}
